package router

import (
	"NanmuHubNIC510/app/api"
	//"NanmuHubNIC510/app/service/auth"
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
)

func MiddlewareCORS(r *ghttp.Request) {
	r.Response.CORSDefault()
	r.Middleware.Next()
}

func init() {
	s := g.Server()
	s.SetDumpRouterMap(true)

	//页面
	s.Group("/", func(g *ghttp.RouterGroup) {
		g.Middleware(MiddlewareCORS)
		g.GET("/", Index.Index)
	})

	//----------------------------------以下API-------------------------------------------

	//API
	s.Group("/Api", func(g *ghttp.RouterGroup) {
		g.Middleware(MiddlewareCORS)
		//g.Middleware(auth.MiddlewareCORS)
		g.GET("/NIC510/Clock", api.GetClock)
		g.POST("/NIC510/Clock", api.SetClock)
		g.PUT("/NIC510/Clock", api.SetClock)
		g.GET("/NIC510/State", api.GetStatus)
		g.GET("/NIC510/Param", api.GetParams)
		g.POST("/NIC510/Param", api.SetParams)
		g.PUT("/NIC510/Param", api.SetParams)
		g.POST("/NIC510/ParamAll", api.SetParamsAll)
		g.PUT("/NIC510/ParamAll", api.SetParamsAll)
	})

}
